package com.ldap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class App {
    private static Log LOG = LogFactory.getLog(App.class);

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) {
        App app = new App();
        // app.testAuthentication();
        // app.testDestroyUserByPrincipal();

        System.out.println("----------------------------");

        app.testAddUser();
        app.testAuthentication();

        // System.out.println("----------------------------");

        app.testChangePassword();
        app.testAuthentication();

        // System.out.println("----------------------------");
        //
        // app.testDestroyUserByPrincipal();
        // app.testAuthentication();
    }

    private void testAddUser() {
        ADUserInfo user = new ADUserInfo();

        user.setSamAccountName("test_7");
        user.setOu("SDMP");
        user.setPassword("12345");

        ADOperator op = new ADOperator();
        op.createUser(user);
    }

    private void testChangePassword() {
        ADUserInfo user = new ADUserInfo();

        user.setSamAccountName("test_7");
        user.setPassword("123456");

        ADOperator op = new ADOperator();
        op.changePassword(user);
    }

    private void testAuthentication() {

        ADOperator op = new ADOperator();
        op.authentication("test_7", "123456");
    }

    private void testDestroyUserByPrincipal() {

        ADOperator op = new ADOperator();
        op.destroyUserByPrincipal("test_7");
    }
}
